function *generate (arr) {
  for (let i in arr) {
    yield arr [i]
  }
  // yield关键字只能在生成器内部使用，一下使用姿势不对，抛出异常
  // arr.forEach(val => {
  //   yield val
  // });
}
let gen = generate(['吃饭', '睡觉', '打豆豆'])
console.log(gen.next())
console.log(gen.next())
console.log(gen.next())
console.log(gen.next())
console.log(gen.next())
console.log(gen.next())
